//
//  ShopTableViewCell.m
//  FreeTrip
//
//  Created by 352324497@qq.com on 15/11/25.
//  Copyright © 2015年 邓芮. All rights reserved.
//

#import "ShopTableViewCell.h"

@implementation ShopTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        CGFloat height = (KScreenWidth / 3) / 680 * 408;
        self.iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10 * KScreenWidth / 375, 10 * KScreenWidth / 375, KScreenWidth / 3, height)];
        [self.contentView addSubview:_iconImageView];
        
        CGFloat x = (10 * KScreenWidth / 375) * 2 + KScreenWidth / 3;
        CGFloat width = KScreenWidth - x - (10 * KScreenWidth / 375);
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, 10 * KScreenWidth / 375, width, height / 3 * 2)];
        self.nameLabel.numberOfLines = 0;
        self.nameLabel.lineBreakMode = 0;
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:_nameLabel];
        
        CGFloat y = 10 * KScreenWidth / 375 + height / 3 * 2;
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height / 3)];
        self.priceLabel.textColor = [UIColor redColor];
        self.priceLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_priceLabel];

    }
    return self;
}

-(void)setModel:(ShopModel *)model
{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.nameLabel.text = model.name;
    self.priceLabel.text = model.price;
}

+(CGFloat)heightForCell
{
    return (KScreenWidth / 3) / 680 * 408 + (10 * KScreenWidth / 375) * 2;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
